package com.cmc.cloud.cmclink.doc.api.document.req.so;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import java.util.ArrayList;
import java.util.List;

/**
 * 特种货审批odo Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 *
 * @author codegen
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SpecialCargoOdoBaseVO {

    private Long id;

    @Schema(description = "箱型ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "23598")
    private Long cntrId;

    @Schema(description = "左侧开门还是右侧开门", requiredMode = Schema.RequiredMode.REQUIRED)
    @Length(max = 64, message = "左侧开门还是右侧开门支持最大长度{max}")
    private String openDirection;

    @Schema(description = "门是否取下", requiredMode = Schema.RequiredMode.REQUIRED)
    private Boolean doorRemove;

    @Schema(description = "门打开的角度")
    @Length(max = 64, message = "门打开的角度支持最大长度{max}")
    private String openAngle;

    @Schema(description = "货物描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便")
    @Length(max = 500, message = "货物描述支持最大长度{max}")
    private String cargoDescription;

    public void validate() {
        List<String> errors = new ArrayList<>();
        if (StringUtils.isEmpty(openDirection)) {
            errors.add("左侧开门还是右侧开门不能为空");
        }
        if (null == doorRemove) {
            errors.add("门是否取下不能为空");
        }
        if (StringUtils.isEmpty(cargoDescription)) {
            errors.add("货物描述不能为空");
        }
        if (!errors.isEmpty()) {
            String errorInfo = String.join(",", errors);
        }
    }
}
